package cc.shacocloud.luanniao.web.model.mo

import cc.shacocloud.luanniao.core.model.constant.UserAuthRoleEnum
import cc.shacocloud.luanniao.core.model.po.UserPo
import kotlinx.serialization.Serializable

/**
 * 用户会话
 *
 * @author 思追(shaco)
 */
@Serializable
data class UserSessionMo(

    /**
     * 会话唯一id
     */
    override val sessionId: String,

    /**
     * 用户id
     */
    val userId: Long,

    /**
     * 用户角色
     */
    override val role: UserAuthRoleEnum,
) : SessionMo() {

    constructor(
        sessionId: String,
        userPo: UserPo,
    ) : this(
        sessionId, requireNotNull(userPo.id), userPo.role
    )
}
